package com.wedo.mall.fragment;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.e.library.fragment.EFragment;
import com.e.library.http.EApi;
import com.e.library.utils.EViewUtils;
import com.jcodecraeer.xrecyclerview.XRecyclerView;
import com.wedo.mall.R;
import com.wedo.mall.activity.order.OrderActivity;
import com.wedo.mall.adapter.OrderAdapter;
import com.wedo.mall.entity.Order;
import com.wedo.mall.ptr.Pull2Refresh;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;

/**
 * A simple {@link Fragment} subclass.
 */
public class OrderPendingEvaluationFragment extends EFragment<OrderActivity> {

    @BindView(R.id.tv_empty) TextView tv_empty;
    @BindView(R.id.rv_list) XRecyclerView rv_list;

    private OrderAdapter orderAdapter;

    private Pull2Refresh<Order> ptr;

    public static OrderPendingEvaluationFragment with(){
        return new OrderPendingEvaluationFragment();
    }


    @Override
    protected int layout() {
        return R.layout.fragment_order_pending_evaluation;
    }

    @Override
    protected void onFragmentCreated(View contentView, Bundle bundle) {
        rv_list.setHasFixedSize(true);
        EViewUtils.vertical(rv_list);
        ptr = new Pull2Refresh<>();

        orderAdapter = new OrderAdapter(this.getActivity(),new ArrayList<Order>());
        orderAdapter.listener(activity());

        Map<String,String> params = new HashMap<>(2);
        params.put("order_type","toBeComment");
        params.put("user_type","buyer");

        ptr.widget(rv_list).adapter(orderAdapter).url(EApi.USER_ORDERLIST).params(params).clazz(Order.class).emptyWidget(tv_empty).done();
    }

}
